
<?php
namespace Home\Controller;
use Think\Controller;
class FormController extends Controller {


    public function index(){
        $db = M('Form');
        $result = $db->select();

        $this->assign('list',$result);
        $this->display();
    }

    public function add(){
    	$this->display();
    }

    public function insert(){
        $code = I('post.vcode');
        $verify = new \think\Verify();
        $ret = $verify->check($code);
        if (!$ret){
            $this->error('验证码错误');
        }
    	$db = M('Form');
    	$data['title'] = I('post.title');
    	$data['content'] = I('post.content');
    	$data['create_time'] = time();
    	$db->add($data);
    }
    public function del($id=0){
        $db = M('data');
        $ret = $db->delete($id);
        if ($ret===false) {
            echo "error!";
        }else {
            echo "影响了：". $ret;
        }
    }

public function vcoda(){
        $config =    array(
            'fontSize'     =>    30,
            'length'       =>    3,
            'useNoise'     =>    false,
            'useImgBg'     =>    false,
        );
        $Verify = new \Think\Verify($config);
        $Verify->entry(); 
    }
}
